//
//  ECAuthorizationTools.h
//  ECAuthorizationTools
//
//  Created by EchoZuo on 2017/6/20.
//  Copyright © 2017年 Echo.Z. All rights reserved.
//

/*
 Abstract：Checking and Requesting Access to Data Classes in Privacy Settings.
 Abstract：检查和请求访问隐私设置数据。
 */


@import Foundation;
@import UIKit;
@import CoreLocation;


#import "Define.h"

/*
 Enumerate
 */
// Privacy classify 分类
typedef NS_ENUM(NSUInteger, ECPrivacyType){
    ECPrivacyType_None                  = 0,
    ECPrivacyType_LocationServices      = 1    // 定位服务
};

// ECAuthorizationStatus 权限状态，参考PHAuthorizationStatus等
typedef NS_ENUM(NSUInteger, ECAuthorizationStatus){
    ECAuthorizationStatus_NotDetermined  = 0, // 用户从未进行过授权等处理，首次访问相应内容会提示用户进行授权
    ECAuthorizationStatus_Authorized     = 1, // 已授权
    ECAuthorizationStatus_Denied         = 2, // 拒绝
    ECAuthorizationStatus_Restricted     = 3, // 应用没有相关权限，且当前用户无法改变这个权限，比如:家长控制
    ECAuthorizationStatus_NotSupport     = 4 // 硬件等不支持
};

// ECLocationAuthorizationStatus 定位权限状态，参考CLAuthorizationStatus
typedef NS_ENUM(NSUInteger, ECLocationAuthorizationStatus){
    ECLocationAuthorizationStatus_NotDetermined         = 0, // 用户从未进行过授权等处理，首次访问相应内容会提示用户进行授权
    ECLocationAuthorizationStatus_Authorized            = 1, // 一直允许获取定位 ps：< iOS8用
    ECLocationAuthorizationStatus_Denied                = 2, // 拒绝
    ECLocationAuthorizationStatus_Restricted            = 3, // 应用没有相关权限，且当前用户无法改变这个权限，比如:家长控制
    ECLocationAuthorizationStatus_NotSupport            = 4, // 硬件等不支持
    ECLocationAuthorizationStatus_AuthorizedAlways      = 5, // 一直允许获取定位
    ECLocationAuthorizationStatus_AuthorizedWhenInUse   = 6 // 在使用时允许获取定位
};

/*
 定义权限状态回调block
 */
typedef void(^AccessForTypeResultBlock)(ECAuthorizationStatus status, ECPrivacyType type);
typedef void(^AccessForLocationResultBlock)(ECLocationAuthorizationStatus status);

@interface ECAuthorizationTools : NSObject

@property (nonatomic, strong) CLLocationManager         *locationManager;       // 定位

#pragma mark -------------------- Public Methods --------------------
/*
 NS_ENUM -> NSString
 */
+ (NSString *)stringForPrivacyType:(ECPrivacyType)privacyType;
+ (NSString *)stringForAuthorizationStatus:(ECAuthorizationStatus)authorizationStatus;
+ (NSString *)stringForLocationAuthorizationStatus:(ECLocationAuthorizationStatus)locationAuthorizationStatus;

#pragma mark -------------------- Main Enter Method --------------------
/**
 Check and request access for LocationServices
 检查和请求定位服务的权限
 
 @param accessStatusCallBack accessStatus
 */
- (void)checkAndRequestAccessForLocationServicesWithAccessStatus:(AccessForLocationResultBlock)accessStatusCallBack;

@end














